package io.gitee.xyuesheng.day08.Thread;

public class TestThread {
    public static void main(String[] args) {
        // 继承Thread类，覆写run方法
        Thread thread = new MyThread();
        thread.start();     // 启动线程
        // thread.run();
        System.out.println("主线程在跑。。。");

        // 实现Runnable接口，实现run方法
        Thread thread2 = new Thread(new MyRunnable());
        thread2.start();

        Thread thread3 = new Thread(new Runnable() {
            @Override
            public void run() {
                System.out.println("匿名内部类线程。。。");
            }
        });
        thread3.start();

        Thread thread4 = new Thread(() -> {
            System.out.println("lambda表达式。。。");
        });
        thread4.start();
    }


    static class MyThread extends Thread {
        @Override
        public void run() {

            System.out.println("自定义线程运行中。。。");
        }
    }

    static class MyRunnable implements Runnable {
        @Override
        public void run() {

            System.out.println("RUnnable线程。。。");
        }
    }


}
